<template>
	<view class="p-30">
		<view v-for="(item,index) in itemList" :key="index" class="w-full p-20 bgfff round-18 flex mb-20">
			<image class="w-40n h-40n" :src="item.item_image" mode="aspectFill"></image>
			<view class="ml-20 flex-1 h-40n flex-col flex-j-b py-6">
				<view class="text-size-32 font-bold text-overflow-1">
					{{item.item_title}}
				</view>
				<view>
					活动名称：{{item.vote_title}}
				</view>
				<view class="text666">
					投票时间：{{dayjs(item.add_time).format('YYYY年MM月DD日 HH:mm:ss')}}
				</view>
			</view>
		</view>
		<uni-load-more :status="loadStatus"></uni-load-more>
	</view>
</template>

<script setup>
	import {
		myVoteList
	} from '@/network/api.js'
	import dayjs from 'dayjs';
	const itemList = ref([])
	const loadStatus = ref('loading')
	const param = reactive({
		limit: 15,
		page: 1
	})
	// 获取我的投票
	const getMyVoteList = async () => {
		loadStatus.value = 'loading'
		const res = await myVoteList({
			...param
		})
		if (res.status === 200) {
			itemList.value = itemList.value.concat(res.data.list)
			loadStatus.value = res.data.list.length > 0 ? 'more' : 'noMore'
		} else {
			uni.showToast({
				title: res.msg,
				icon: 'none'
			})
			loadStatus.value = 'more'
		}
	}
	onReachBottom(() => {
		if (loadStatus.value === 'more') {
			param.page++
			getMyVoteList()
		}
	})
	onLoad(() => {
		getMyVoteList()
	})
</script>

<style>

</style>